/**
 * @file       DigitChar_test.cpp
 * @brief      TODO
 * @author     Huabo Zheng
 * @date       Jan 12, 2012
 * @Copyright  2012, www.netgear.com Inc. All rights reserved.
 */

#include "DigitChar.h"
#include "gtest/gtest.h"
#include "errorcode.h"
namespace NS_LCD_AFW
{
class CDigitChar_test: public ::testing::Test

{
public:
	virtual void SetUp()
	{
	}
	virtual void TearDown()
	{
	}
};
TEST_F(CDigitChar_test,test_defualtConstruction)
{
	CDigitChar *pChar = new CDigitChar();
	EXPECT_TRUE(pChar->isHightlightable());
	EXPECT_TRUE(pChar->isFocusable());
	EXPECT_EQ(' ',pChar->getChar());
	OBJ_DESTORY(pChar);
}
TEST_F(CDigitChar_test,test_setChar)
{
	CDigitChar *pChar = new CDigitChar();
	EXPECT_TRUE(pChar->isHightlightable());
	EXPECT_TRUE(pChar->isFocusable());

	pChar->setChar('.');
	EXPECT_EQ('.',pChar->getChar());
	EXPECT_FALSE(pChar->isHightlightable());
	EXPECT_FALSE(pChar->isFocusable());

	pChar->setChar(' ');
	EXPECT_EQ(' ',pChar->getChar());

	pChar->setChar('0');
	EXPECT_EQ('0',pChar->getChar());

	pChar->setChar(47);
	EXPECT_EQ('0',pChar->getChar());

	pChar->setChar('9');
	EXPECT_EQ('9',pChar->getChar());

	pChar->setChar(58);
	EXPECT_EQ('9',pChar->getChar());
	OBJ_DESTORY(pChar);
}
TEST_F(CDigitChar_test,test_onUpKeyPress)
{
	CFrame *pChar = new CDigitChar();
	EXPECT_TRUE(pChar->isHightlightable());
	EXPECT_TRUE(pChar->isFocusable());
	EXPECT_EQ(' ',((CDigitChar *)pChar)->getChar());
	EXPECT_EQ(ERR_SUCCESS,pChar->onUpKeyPress());
	EXPECT_EQ('0',((CDigitChar *)pChar)->getChar());
	EXPECT_EQ(ERR_SUCCESS,pChar->onUpKeyPress());
	EXPECT_EQ('1',((CDigitChar *)pChar)->getChar());
	((CDigitChar *)pChar)->setChar('9');
	EXPECT_EQ(ERR_SUCCESS,pChar->onUpKeyPress());
	EXPECT_EQ(' ',((CDigitChar *)pChar)->getChar());
	OBJ_DESTORY(pChar);
}
TEST_F(CDigitChar_test,test_onDownKeyPress)
{
	CFrame *pChar = new CDigitChar();
	EXPECT_TRUE(pChar->isHightlightable());
	EXPECT_TRUE(pChar->isFocusable());
	EXPECT_EQ(' ',((CDigitChar *)pChar)->getChar());
	EXPECT_EQ(ERR_SUCCESS,pChar->onDownKeyPress());
	EXPECT_EQ('9',((CDigitChar *)pChar)->getChar());
	EXPECT_EQ(ERR_SUCCESS,pChar->onDownKeyPress());
	EXPECT_EQ('8',((CDigitChar *)pChar)->getChar());
	((CDigitChar *)pChar)->setChar('0');
	EXPECT_EQ(ERR_SUCCESS,pChar->onDownKeyPress());
	EXPECT_EQ(' ',((CDigitChar *)pChar)->getChar());
	OBJ_DESTORY(pChar);
}
} /* namespace NS_LCD_AFW */
